package com.mydemo.springlearning.functions.CRUDdemo.byxml.controller;


import com.mydemo.springlearning.functions.CRUDdemo.entity.User;
import com.mydemo.springlearning.functions.CRUDdemo.byxml.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("/")
public class TestController {

    @Autowired
    private UserService userService;


    @RequestMapping("/")
    public String test() {
        return "test ok";
    }

    @RequestMapping("add")
    public String testAdd(String name) {
        User user = new User();
        user.setUserName(name);
        userService.add(user);
        return "add ok";
    }


    @RequestMapping("getAll")
    public List<User> getAllUsers(){
        return userService.getAllUsers();
    }

}
